#include <stdio.h>

#include <queue>
#include <set>

using namespace std;

#define MAXN (10)
int vis[MAXN][MAXN];

struct Pos {
  int i;
  int j;
  int steps;

  Pos(int i_, int j_) {
    i = i_;
    j = j_;
  }
  int Hash() const { return i * MAXN + j; }
  bool operator==(Pos other) const { return i == other.i && j == other.j; }
  Pos& operator=(Pos other) {
    i = other.i;
    j = other.j;
    return *this;
  }
  Pos() {
    i = j = -1;
    steps = 0;
  }
  bool InBound() const { return 1 <= i && i <= MAXN && 1 <= j && j <= MAXN; }
};

Pos From, To;

void Read() {
  scanf("%d%d%d%d", &From.i, &From.j, &To.i, &To.j);
  //
}

const int Dx[][2] = {
    {2, 1},  {1, 2},  {-2, -1}, {-1, -2},  //
    {-2, 1}, {-1, 2}, {2, -1},  {1, -2},
};

void BFS() {
  queue<Pos> Q;
  Q.push(From);
  vis[From.i][From.j] = 1;

  while (!Q.empty()) {
    Pos now = Q.front();
    Q.pop();
    if (now == To) {
      printf("%d\n", now.steps);
      return;
    }
    for (int i = 0; i < 8; ++i) {
      Pos Next = now;
      Next.i += Dx[i][0];
      Next.j += Dx[i][1];
      if (!Next.InBound() || vis[Next.i][Next.j]) {
        continue;
      }
      Next.steps = now.steps + 1;
      Q.push(Next);
      vis[Next.i][Next.j] = 1;
    }
  }
  puts("-1");
}

int main() {
  freopen("in2.txt", "r", stdin);

  Read();
  BFS();
  return 0;
}